unit UPesquisaRelatorioMovimentoDocumento;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UrelatorioBase, RLPDFFilter, RLXLSFilter, RLFilters,
  RLHTMLFilter, RLDraftFilter, DB, DBTables, RLReport, StdCtrls, ExtCtrls,
  Buttons, CheckLst, DBCtrls, Mask, ToolEdit;

type
  TFRelatorioMovimentacaoDocumento = class(TFrelatorioBase)
    Label10: TLabel;
    CLBEmpresas: TCheckListBox;
    GBDtLancamento: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    DtPeriodo1: TDateEdit;
    DtPeriodo2: TDateEdit;
    Label3: TLabel;
    EdDocumento: TEdit;
    Label4: TLabel;
    DBLCBTipoMovimento: TDBLookupComboBox;
    Label7: TLabel;
    DBLCBLocal: TDBLookupComboBox;
    DSLocal: TDataSource;
    DSTipoMovimentoEstoque: TDataSource;
    procedure FormCreate(Sender: TObject);
    procedure DBLCBTipoMovimentoEnter(Sender: TObject);
    procedure DBLCBTipoMovimentoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btnPesquisarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FRelatorioMovimentacaoDocumento: TFRelatorioMovimentacaoDocumento;

implementation

uses UGeral, UDMGeral;

{$R *.dfm}

procedure TFRelatorioMovimentacaoDocumento.FormCreate(Sender: TObject);
begin

  Usando_Query_Pesquisa(' SELECT             '+
                        '       EMP_CODIGO,  '+
                        '       EMP_FANTASIA '+
                        ' FROM EMPRESA       ');

  Query_Pesquisa.First;

  CLBEmpresas.Items.Clear;

  while not (Query_Pesquisa.Eof) do
  begin

    CLBEmpresas.Items.Add(Query_Pesquisa.fieldByname('EMP_CODIGO').AsString + '-' + Query_Pesquisa.fieldByname('EMP_FANTASIA').AsString);
    Query_Pesquisa.Next;

  end;

  Query_Pesquisa.Close;

  CLBEmpresas.Checked[0] := true;

  inherited;

end;

procedure TFRelatorioMovimentacaoDocumento.DBLCBTipoMovimentoEnter(
  Sender: TObject);
begin
  inherited;
  if not(TDBLookupComboBox(Sender).ListSource.DataSet.Active) then
    TDBLookupComboBox(Sender).ListSource.DataSet.Open;
end;

procedure TFRelatorioMovimentacaoDocumento.DBLCBTipoMovimentoKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  
  case key of
  114 : ShowMessage(TDBLookupComboBox(Sender).Text);

  116 : begin
           TDBLookupComboBox(Sender).ListSource.DataSet.Close;
           TDBLookupComboBox(Sender).ListSource.DataSet.Open;
          end ;
  end;

 if key = 46 then
   TDBLookupComboBox(Sender).KeyValue := null;

end;

procedure TFRelatorioMovimentacaoDocumento.btnPesquisarClick(
  Sender: TObject);
const ctSql = ' SELECT '+#10+
              '         MOVIEMTNO';
begin
  inherited;

end;

end.
